/**
 * 去除尾部多余的空白字符
 */

#include <stdio.h>
#include <string.h>

int trim(char s[]);

int main(void) {
    char s[] = "Hello! I aslfdkj   asldf j   asdf   \t\n\n\t\n";
    printf("length: %d, %s", strlen(s), s);
    trim(s);
    printf("length: %d, %s", strlen(s), s);

    return 0;
}

int trim(char s[]) {
    int i;
    for (i = strlen(s) - 1; i >= 0; i--) {
        if (s[i] != ' ' && s[i] != '\t' && s[i] != '\n')
            break;
    }
    s[i+1] = '\0';
    return i;
}
